#!/bin/bash

SRCROOT=$1
SVN_BIN=`which svn`

if [ -d "${SRCROOT}/../../.svn" ]; then
    if [ "${SVN_BIN}" != "" ]; then
		SVN_URL=`svn info ${SRCROOT} | awk '{if (NR==3) print $2}'`
		SVN_VERSION=`svn info ${SRCROOT} | awk '{if (NR==7) print $2}'`
    fi
else
    #加入git svn info也可以取得信息
    if [ "${SVN_URL}" == "" ]; then
		SVN_URL=`cd ${SRCROOT} && git svn info | awk '{if (NR==3) print $2}'`
		SVN_VERSION=`cd ${SRCROOT} &&  git svn info | awk '{if (NR==7) print $2}'`
    fi
fi

SVN_URL_str="url"
SVN_version_str="revision"
if [ "$2" = ${SVN_URL_str} ]; then
	echo ${SVN_URL}
elif [ "$2" = ${SVN_version_str} ]; then
	echo ${SVN_VERSION}
fi